<html>
<head><meta charset="utf-8"><title>Getting all errors collected so far from TyCtxt? · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Getting.20all.20errors.20collected.20so.20far.20from.20TyCtxt.3F.html">Getting all errors collected so far from TyCtxt?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="223344319"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Getting%20all%20errors%20collected%20so%20far%20from%20TyCtxt%3F/near/223344319" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> osa1 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Getting.20all.20errors.20collected.20so.20far.20from.20TyCtxt.3F.html#223344319">(Jan 20 2021 at 08:35)</a>:</h4>
<p>Given a <code>TyCtxt</code> is there a way to get all errors collected so far? I looked at the methods but couldn't see anything relevant. I also checked <code>Handler</code> methods.</p>



<a name="223379284"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Getting%20all%20errors%20collected%20so%20far%20from%20TyCtxt%3F/near/223379284" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Getting.20all.20errors.20collected.20so.20far.20from.20TyCtxt.3F.html#223379284">(Jan 20 2021 at 14:31)</a>:</h4>
<p>There's err_count: <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_errors/struct.Handler.html#method.err_count">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_errors/struct.Handler.html#method.err_count</a><br>
I don't know if you can get the errors themselves</p>



<a name="223379374"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Getting%20all%20errors%20collected%20so%20far%20from%20TyCtxt%3F/near/223379374" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Getting.20all.20errors.20collected.20so.20far.20from.20TyCtxt.3F.html#223379374">(Jan 20 2021 at 14:31)</a>:</h4>
<p>(deleted)</p>



<a name="223379403"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Getting%20all%20errors%20collected%20so%20far%20from%20TyCtxt%3F/near/223379403" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Getting.20all.20errors.20collected.20so.20far.20from.20TyCtxt.3F.html#223379403">(Jan 20 2021 at 14:32)</a>:</h4>
<p>Why do you want to see the errors?</p>



<a name="223380176"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Getting%20all%20errors%20collected%20so%20far%20from%20TyCtxt%3F/near/223380176" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Getting.20all.20errors.20collected.20so.20far.20from.20TyCtxt.3F.html#223380176">(Jan 20 2021 at 14:37)</a>:</h4>
<p>If you are using a custom driver, you can use <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_driver/struct.RunCompiler.html#method.set_emitter"><code>RunCompiler::set_emitter</code></a> to record all emitted diagnostics. The <code>Handler</code> only stores hashes of previously emitted diagnostics: <a href="https://github.com/rust-lang/rust/blob/a4cbb44ae2c80545db957763b502dc7f6ea22085/compiler/rustc_errors/src/lib.rs#L289-L292">https://github.com/rust-lang/rust/blob/a4cbb44ae2c80545db957763b502dc7f6ea22085/compiler/rustc_errors/src/lib.rs#L289-L292</a> I don't think there is any place that stores all emitted diagnostics.</p>



<a name="223383034"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Getting%20all%20errors%20collected%20so%20far%20from%20TyCtxt%3F/near/223383034" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> osa1 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Getting.20all.20errors.20collected.20so.20far.20from.20TyCtxt.3F.html#223383034">(Jan 20 2021 at 14:56)</a>:</h4>
<p><span class="user-mention silent" data-user-id="232545">Joshua Nelson</span> <a href="#narrow/stream/182449-t-compiler.2Fhelp/topic/Getting.20all.20errors.20collected.20so.20far.20from.20TyCtxt.3F/near/223379403">said</a>:</p>
<blockquote>
<p>Why do you want to see the errors?</p>
</blockquote>
<p>There's a panic in const eval and we think the code path should not be taken because of a previous type error. I want to see whether the error is emitted or not (and for the right definition).</p>



<a name="223383283"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Getting%20all%20errors%20collected%20so%20far%20from%20TyCtxt%3F/near/223383283" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Getting.20all.20errors.20collected.20so.20far.20from.20TyCtxt.3F.html#223383283">(Jan 20 2021 at 14:58)</a>:</h4>
<p>You could probably add some flag like <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TypeckResults.html#structfield.tainted_by_errors"><code>TypeckResults::tainted_by_errors</code></a>.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>